import time
def sor(s):
    swapped = True
    while swapped:
        swapped = False
        for i in range (len(s) - 1):
                if s[i] > s[i + 1]:
                    s[i], s[i + 1] = s[i + 1], s[i]
                    swapped = True
                    
def read2list(filename):
    file = open(filename, "r")
    data = file.readlines()
    return data

m1 = read2list("m1_sorted.txt")
m2 = read2list("m2_reverse.txt")
m3 = read2list("m3_shuffle.txt")

ts = time.time()
sor(m1)
tf = time.time()
print(round(tf - ts) * 1000)

ts = time.time()
sor(m2)
tf = time.time()
print(round(tf - ts) * 1000)

ts = time.time()
sor(m3)
tf = time.time()
print(round(tf - ts) * 1000)
 
